package org.devocean.groupbuying.service.impl;

import org.devocean.groupbuying.dao.ArticlesLocalizationDAO;
import org.devocean.groupbuying.domain.ArticlesLocalization;
import org.devocean.groupbuying.service.ArticlesLocalizationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class ArticlesLocalizationServiceImpl implements
		ArticlesLocalizationService {

	@Autowired
	private ArticlesLocalizationDAO articlesLocalizationDAO;


	@Transactional
	public ArticlesLocalization addOrUpdateArticlesLocalization(
			ArticlesLocalization articlesLocalization) {

		if (articlesLocalization.getArticlesLocalizationID() == null) {
			return articlesLocalizationDAO
					.saveArticlesLocalization(articlesLocalization);

		} else
			return articlesLocalizationDAO
					.updateArticlesLocalization(articlesLocalization);

	}

	@Transactional(readOnly = true)
	public ArticlesLocalization getArticleById(Integer articleId) {
		return articlesLocalizationDAO.findArticleById(articleId);
	}

	@Transactional
	public void removeArticlesLocalization(Integer id) {

		articlesLocalizationDAO.deleteArticlesLocalization(id);

	}

	@Transactional(readOnly = true)
	public ArticlesLocalization getArticleBylang(Integer LocalizationKey,String language) {
			
		return articlesLocalizationDAO.findArticleBylang(LocalizationKey,
				language);



	}



}
